﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using webapp4U.BOL;

namespace webapp4U.UI
{
    public partial class ArticleDefault : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int CateID = Globals.GetIntFromQueryString("CateID");
            if (CateID > 0)
            {
                Title011.TitleName = ArticleCategory.GetCateNameByCateID(CateID);

                List<webapp4U.BOL.Article> obj = webapp4U.BOL.Article.GetArticleByParentID(CateID);
                rptArticles.DataSource = obj;
                rptArticles.DataBind();

                this.Load_Title(CateID);
            }
            else
                CateID = Globals.ConvertToInt32(eCategory.TinTucOnline);
        }




        private void Load_Title(int CateID)
        {
            try
            {
                if (CateID > 0)
                {
                    // kiem tra xem can hien thi san pham hinh thuc nao
                    List<webapp4U.BOL.ArticleCategory> obj = webapp4U.BOL.ArticleCategory.GetArticleCategoryByParentID(CateID);
                    // xem loai cha
                    if (obj.Count > 0)
                    {
                        Title011.TitleName = ArticleCategory.GetCateNameByCateID(CateID);
                        ArticlesByParent11.Visible = true;
                        PanelArticles.Visible = false;
                    }
                    else
                    {
                        ArticleCategory cate = ArticleCategory.GetArticleCategoryByID(CateID);
                        Title011.TitleName = ArticleCategory.GetCateNameByCateID(cate.ParentID) + " <img src=" + Globals.ImagesUrl() + "li1.gif align='absmiddle'> " + ArticleCategory.GetCateNameByCateID(CateID);

                        ArticlesByParent11.Visible = false;
                        PanelArticles.Visible = true;
                    }
                }
                else
                {
                    Title011.TitleName = Globals.GetLang("Tin tức", "News");
                }
            }
            catch
            { 
                
            }
        }


    }
}
